/**
 * 
 */
package cn.imeth.android.camera;

import android.app.Fragment;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;

/**
 * @author Adi (adi@imeth.cn)
 *
 */
public class CameraPermissionErrorFragment extends Fragment {

	public static Fragment newInstance() {
		CameraPermissionErrorFragment fragment = new CameraPermissionErrorFragment();
		return fragment;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		View view = inflater.inflate(R.layout.fragment_permission_error_layout,
				null);

		view.findViewById(R.id.back_btn).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						getActivity().finish();
					}
				});

		view.findViewById(R.id.setting_btn).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
						intent.setData(Uri.fromParts("package", getActivity().getPackageName(), null));
						try {
							getActivity().startActivityForResult(intent, 0);
						} catch (Exception e) {
							e.printStackTrace();
						}
					}
				});

		return view;
	}
}
